<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Command-module for direct opening of user-defined targets &mdash; Dragonfly-modules v0.1 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.1',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Dragonfly-modules v0.1 documentation" href="index.html" />
    <link rel="next" title="Command-module for screen locking" href="mod-_lockscreen.html" />
    <link rel="prev" title="Command-module for taskbar and icon tray access" href="mod-_taskbar.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="mod-_lockscreen.html" title="Command-module for screen locking"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mod-_taskbar.html" title="Command-module for taskbar and icon tray access"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Dragonfly-modules v0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="command-module-for-direct-opening-of-user-defined-targets">
<h1>Command-module for direct opening of <strong>user-defined targets</strong><a class="headerlink" href="#command-module-for-direct-opening-of-user-defined-targets" title="Permalink to this headline">¶</a></h1>
<p>This module offers very easy and direct opening of user-
defined targets.  User define their own targets in the
configuration file, and then have instant access to them
by saying &#8220;bring me &lt;target&gt;&#8221;.  The configuration file
format is described below.</p>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<p>If you are using DNS and Natlink, simply place this file in you Natlink
macros directory.  It will then be automatically loaded by Natlink when
you next toggle your microphone or restart Natlink.</p>
</div>
<div class="section" id="commands">
<h2>Commands<a class="headerlink" href="#commands" title="Permalink to this headline">¶</a></h2>
<dl class="docutils">
<dt>Command: <strong>&#8220;bring me &lt;target&gt;&#8221;</strong></dt>
<dd>Open the specified target.
The <em>&lt;target&gt;</em> extra in this rule can be any one
of the targets defined in this module&#8217;s configuration file.</dd>
<dt>Command: <strong>&#8220;paste me &lt;target&gt;&#8221;</strong></dt>
<dd>Paste the address of the specified target.
The <em>&lt;target&gt;</em> extra is the same as for the bring me command.</dd>
</dl>
</div>
<div class="section" id="customization">
<h2>Customization<a class="headerlink" href="#customization" title="Permalink to this headline">¶</a></h2>
<p>Users should customize this module by editing its configuration
file.  In this file they should fill the <tt class="docutils literal"><span class="pre">targets.mapping</span></tt>
with their own personal targets.  This target mapping maps <em>what
you say</em> to <em>which target to open</em>.</p>
<p>For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">targets</span><span class="o">.</span><span class="n">mapping</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">&quot;[my] favorite website&quot;</span><span class="p">:</span> <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://code.google.com/p/dragonfly&quot;</span><span class="p">),</span>
    <span class="s">&quot;my local folder&quot;</span><span class="p">:</span>       <span class="n">folder</span><span class="p">(</span><span class="s">r&quot;C:&quot;</span><span class="p">),</span>
   <span class="p">}</span>
</pre></div>
</div>
<p>(Note the format of each target: <tt class="docutils literal"><span class="pre">&quot;...&quot;:</span> <span class="pre">type(&quot;...&quot;),</span></tt>
And note the use of <tt class="docutils literal"><span class="pre">r&quot;...&quot;</span></tt> when specifying a path
containing backslash characters; the <em>r</em> in front of the
open-quote means that backslashes can be given literally
and <em>don&#8217;t</em> need to be doubled.)</p>
<p>Using the configuration above would allow the user to say:</p>
<blockquote>
<ul class="simple">
<li><strong>&#8220;bring me my favorite website&#8221;</strong> and the Dragonfly homepage
will be opened.</li>
<li><strong>&#8220;bring me my local folder&#8221;</strong> and a Windows Explorer
will be opened showing the local <tt class="docutils literal"><span class="pre">C:\</span></tt> folder.</li>
</ul>
</blockquote>
</div>
<div class="section" id="configuration-examples">
<h2>Configuration examples<a class="headerlink" href="#configuration-examples" title="Permalink to this headline">¶</a></h2>
<div class="section" id="configuration-bringme-en-txt">
<h3>Configuration &#8220;_bringme-en.txt&#8221;<a class="headerlink" href="#configuration-bringme-en-txt" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28</pre></td><td class="code"><div class="highlight"><pre><span class="c">#--- Targets section -------------------------------------------------------</span>

<span class="n">targets</span><span class="o">.</span><span class="n">mapping</span> <span class="o">=</span> <span class="p">{</span>

    <span class="c"># Python-specific targets.</span>
    <span class="s">&quot;(python | pie) (library | lib)&quot;</span><span class="p">:</span>      <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://docs.python.org/library/&quot;</span><span class="p">),</span>
    <span class="s">&quot;(python | pie) home&quot;</span><span class="p">:</span>                 <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://www.python.org/&quot;</span><span class="p">),</span>

    <span class="c"># Dragonfly-specific targets.</span>
    <span class="s">&quot;dragonfly page&quot;</span><span class="p">:</span>                      <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://code.google.com/p/dragonfly/&quot;</span><span class="p">),</span>
    <span class="s">&quot;dragonfly modules page&quot;</span><span class="p">:</span>              <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://code.google.com/p/dragonfly-modules/&quot;</span><span class="p">),</span>
    <span class="s">&quot;speech computing&quot;</span><span class="p">:</span>                    <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://www.speechcomputing.com/forum&quot;</span><span class="p">),</span>
    <span class="s">&quot;[natlink] macros&quot;</span><span class="p">:</span>                    <span class="n">folder</span><span class="p">(</span><span class="s">r&quot;C:\Program Files\NatLink\MacroSystem&quot;</span><span class="p">),</span>
    <span class="s">&quot;dragonfly lib&quot;</span><span class="p">:</span>                       <span class="n">folder</span><span class="p">(</span><span class="s">r&quot;C:\Python25\Lib\site-packages\dragonfly&quot;</span><span class="p">),</span>

   <span class="p">}</span>

<span class="c">#--- Language section ------------------------------------------------------</span>

<span class="n">lang</span><span class="o">.</span><span class="n">bring_me</span> <span class="o">=</span> <span class="s">&quot;bring me &lt;target&gt;&quot;</span>
                    <span class="c"># Command to bring a target; must contain the</span>
                    <span class="c">#  &lt;target&gt; extra.</span>
                    <span class="c"># Default: &quot;bring me &lt;target&gt;&quot;</span>

<span class="n">lang</span><span class="o">.</span><span class="n">paste_me</span> <span class="o">=</span> <span class="s">&quot;paste me &lt;target&gt;&quot;</span>
                    <span class="c"># Command to paste the location of a target;</span>
                    <span class="c">#  must contain the &lt;target&gt; extra.</span>
                    <span class="c"># Default: &quot;bring me &lt;target&gt;&quot;</span>
</pre></div>
</td></tr></table></div>
</div>
</div>
<div class="section" id="module-source-code">
<h2>Module source code<a class="headerlink" href="#module-source-code" title="Permalink to this headline">¶</a></h2>
<p>The most current version of this module can be downloaded from the <a class="reference external" href="http://dragonfly-modules.googlecode.com/svn/trunk/command-modules/_bringme.py">repository here</a>.</p>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre>  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184</pre></td><td class="code"><div class="highlight"><pre><span class="c">#</span>
<span class="c"># This file is a command-module for Dragonfly.</span>
<span class="c"># (c) Copyright 2008 by Christo Butcher</span>
<span class="c"># Licensed under the LGPL, see &lt;http://www.gnu.org/licenses/&gt;</span>
<span class="c">#</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Command-module for direct opening of **user-defined targets**</span>
<span class="sd">============================================================================</span>

<span class="sd">This module offers very easy and direct opening of user-</span>
<span class="sd">defined targets.  User define their own targets in the</span>
<span class="sd">configuration file, and then have instant access to them</span>
<span class="sd">by saying &quot;bring me &lt;target&gt;&quot;.  The configuration file</span>
<span class="sd">format is described below.</span>

<span class="sd">Installation</span>
<span class="sd">----------------------------------------------------------------------------</span>

<span class="sd">If you are using DNS and Natlink, simply place this file in you Natlink</span>
<span class="sd">macros directory.  It will then be automatically loaded by Natlink when</span>
<span class="sd">you next toggle your microphone or restart Natlink.</span>

<span class="sd">Commands</span>
<span class="sd">----------------------------------------------------------------------------</span>

<span class="sd">Command: **&quot;bring me &lt;target&gt;&quot;**</span>
<span class="sd">    Open the specified target.</span>
<span class="sd">    The *&lt;target&gt;* extra in this rule can be any one</span>
<span class="sd">    of the targets defined in this module&#39;s configuration file.</span>

<span class="sd">Command: **&quot;paste me &lt;target&gt;&quot;**</span>
<span class="sd">    Paste the address of the specified target.</span>
<span class="sd">    The *&lt;target&gt;* extra is the same as for the bring me command.</span>

<span class="sd">Customization</span>
<span class="sd">----------------------------------------------------------------------------</span>

<span class="sd">Users should customize this module by editing its configuration</span>
<span class="sd">file.  In this file they should fill the ``targets.mapping``</span>
<span class="sd">with their own personal targets.  This target mapping maps *what</span>
<span class="sd">you say* to *which target to open*.</span>

<span class="sd">For example:</span>

<span class="sd">.. code-block:: python</span>

<span class="sd">   targets.mapping = {</span>
<span class="sd">       &quot;[my] favorite website&quot;: website(&quot;http://code.google.com/p/dragonfly&quot;),</span>
<span class="sd">       &quot;my local folder&quot;:       folder(r&quot;C:\&quot;),</span>
<span class="sd">      }</span>

<span class="sd">(Note the format of each target: ``&quot;...&quot;: type(&quot;...&quot;),``</span>
<span class="sd">And note the use of ``r&quot;...&quot;`` when specifying a path</span>
<span class="sd">containing backslash characters; the *r* in front of the</span>
<span class="sd">open-quote means that backslashes can be given literally</span>
<span class="sd">and *don&#39;t* need to be doubled.)</span>

<span class="sd">Using the configuration above would allow the user to say:</span>

<span class="sd"> - **&quot;bring me my favorite website&quot;** and the Dragonfly homepage</span>
<span class="sd">   will be opened.</span>
<span class="sd"> - **&quot;bring me my local folder&quot;** and a Windows Explorer</span>
<span class="sd">   will be opened showing the local ``C:\`` folder.</span>

<span class="sd">&quot;&quot;&quot;</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">import</span> <span class="nn">pkg_resources</span>
    <span class="n">pkg_resources</span><span class="o">.</span><span class="n">require</span><span class="p">(</span><span class="s">&quot;dragonfly &gt;= 0.6.5beta1.dev-r76&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="k">pass</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">os.path</span>
<span class="kn">import</span> <span class="nn">webbrowser</span>
<span class="kn">import</span> <span class="nn">subprocess</span>

<span class="kn">from</span> <span class="nn">dragonfly</span> <span class="kn">import</span> <span class="p">(</span><span class="n">Grammar</span><span class="p">,</span> <span class="n">Choice</span><span class="p">,</span> <span class="n">CompoundRule</span><span class="p">,</span>
                       <span class="n">Paste</span><span class="p">,</span> <span class="n">Config</span><span class="p">,</span> <span class="n">Section</span><span class="p">,</span> <span class="n">Item</span><span class="p">)</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Bringable classes.</span>

<span class="k">class</span> <span class="nc">BringableBase</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">target</span> <span class="o">=</span> <span class="n">target</span>
    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s">(</span><span class="si">%r</span><span class="s">)&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">)</span>
    <span class="n">__str__</span> <span class="o">=</span> <span class="n">__repr__</span>
    <span class="k">def</span> <span class="nf">bring_it</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">pass</span>

<span class="k">class</span> <span class="nc">website</span><span class="p">(</span><span class="n">BringableBase</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">bring_it</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s">r&quot;C:\Program Files\Mozilla Firefox\firefox.exe&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">])</span>
<span class="c">#        webbrowser.open(self.target)</span>

<span class="k">class</span> <span class="nc">folder</span><span class="p">(</span><span class="n">BringableBase</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">bring_it</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span>
        <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s">&quot;explorer&quot;</span><span class="p">,</span> <span class="n">target</span><span class="p">])</span>

<span class="k">class</span> <span class="nc">open</span><span class="p">(</span><span class="n">BringableBase</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">verb</span><span class="o">=</span><span class="s">&quot;open&quot;</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">verb</span> <span class="o">=</span> <span class="n">verb</span>
        <span class="n">BringableBase</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">)</span>
    <span class="k">def</span> <span class="nf">bring_it</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span>
        <span class="n">os</span><span class="o">.</span><span class="n">startfile</span><span class="p">(</span><span class="n">target</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">verb</span><span class="p">)</span>

<span class="k">class</span> <span class="nc">ssh</span><span class="p">(</span><span class="n">BringableBase</span><span class="p">):</span>
    <span class="n">putty_path</span> <span class="o">=</span> <span class="s">r&quot;C:\Program Files\PuTTY\putty&quot;</span>
    <span class="k">def</span> <span class="nf">bring_it</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">putty_path</span><span class="p">,</span> <span class="s">&quot;-load&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">])</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Set up this module&#39;s configuration.</span>

<span class="n">config</span> <span class="o">=</span> <span class="n">Config</span><span class="p">(</span><span class="s">&quot;bring me&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">targets</span>         <span class="o">=</span> <span class="n">Section</span><span class="p">(</span><span class="s">&quot;Targets section&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">targets</span><span class="o">.</span><span class="n">mapping</span> <span class="o">=</span> <span class="n">Item</span><span class="p">(</span>
                              <span class="n">default</span><span class="o">=</span><span class="p">{</span>
                                       <span class="s">&quot;my site&quot;</span><span class="p">:</span> <span class="n">website</span><span class="p">(</span><span class="s">&quot;http://www.google.com&quot;</span><span class="p">),</span>
                                      <span class="p">},</span>
                              <span class="n">doc</span><span class="o">=</span><span class="s">&quot;Mapping of spoken targets to bringable targets.&quot;</span><span class="p">,</span>
                              <span class="n">namespace</span><span class="o">=</span><span class="p">{</span>
                                         <span class="s">&quot;website&quot;</span><span class="p">:</span>  <span class="n">website</span><span class="p">,</span>
                                         <span class="s">&quot;open&quot;</span><span class="p">:</span>     <span class="nb">open</span><span class="p">,</span>
                                         <span class="s">&quot;folder&quot;</span><span class="p">:</span>   <span class="n">folder</span><span class="p">,</span>
                                         <span class="s">&quot;ssh&quot;</span><span class="p">:</span>      <span class="n">ssh</span><span class="p">,</span>
                                        <span class="p">},</span>
                             <span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span>            <span class="o">=</span> <span class="n">Section</span><span class="p">(</span><span class="s">&quot;Language section&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">bring_me</span>   <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;bring me &lt;target&gt;&quot;</span><span class="p">,</span>
                              <span class="n">doc</span><span class="o">=</span><span class="s">&quot;Command to bring a target;&quot;</span>
                                  <span class="s">&quot; must contain the &lt;target&gt; extra.&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">paste_me</span>   <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;paste me &lt;target&gt;&quot;</span><span class="p">,</span>
                              <span class="n">doc</span><span class="o">=</span><span class="s">&quot;Command to paste the location of a target;&quot;</span>
                                  <span class="s">&quot; must contain the &lt;target&gt; extra.&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Bring rule.</span>

<span class="k">class</span> <span class="nc">BringRule</span><span class="p">(</span><span class="n">CompoundRule</span><span class="p">):</span>

    <span class="n">spec</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">bring_me</span>
    <span class="n">extras</span> <span class="o">=</span> <span class="p">[</span><span class="n">Choice</span><span class="p">(</span><span class="s">&quot;target&quot;</span><span class="p">,</span> <span class="n">config</span><span class="o">.</span><span class="n">targets</span><span class="o">.</span><span class="n">mapping</span><span class="p">)]</span>

    <span class="k">def</span> <span class="nf">_process_recognition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">,</span> <span class="n">extras</span><span class="p">):</span>
        <span class="n">target</span> <span class="o">=</span> <span class="n">extras</span><span class="p">[</span><span class="s">&quot;target&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s">: bringing target </span><span class="si">%s</span><span class="s">.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">))</span>
        <span class="n">target</span><span class="o">.</span><span class="n">bring_it</span><span class="p">()</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Paste rule.</span>

<span class="k">class</span> <span class="nc">PasteRule</span><span class="p">(</span><span class="n">CompoundRule</span><span class="p">):</span>

    <span class="n">spec</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">paste_me</span>
    <span class="n">extras</span> <span class="o">=</span> <span class="p">[</span><span class="n">Choice</span><span class="p">(</span><span class="s">&quot;target&quot;</span><span class="p">,</span> <span class="n">config</span><span class="o">.</span><span class="n">targets</span><span class="o">.</span><span class="n">mapping</span><span class="p">)]</span>

    <span class="k">def</span> <span class="nf">_process_recognition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">,</span> <span class="n">extras</span><span class="p">):</span>
        <span class="n">target</span> <span class="o">=</span> <span class="n">extras</span><span class="p">[</span><span class="s">&quot;target&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s">: pasting target </span><span class="si">%s</span><span class="s">.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target</span><span class="p">))</span>
        <span class="n">Paste</span><span class="p">(</span><span class="n">target</span><span class="o">.</span><span class="n">target</span><span class="p">)</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Create and manage this module&#39;s grammar.</span>

<span class="n">grammar</span> <span class="o">=</span> <span class="n">Grammar</span><span class="p">(</span><span class="s">&quot;bring me&quot;</span><span class="p">)</span>
<span class="n">grammar</span><span class="o">.</span><span class="n">add_rule</span><span class="p">(</span><span class="n">BringRule</span><span class="p">())</span>
<span class="n">grammar</span><span class="o">.</span><span class="n">add_rule</span><span class="p">(</span><span class="n">PasteRule</span><span class="p">())</span>
<span class="n">grammar</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">unload</span><span class="p">():</span>
    <span class="k">global</span> <span class="n">grammar</span>
    <span class="k">if</span> <span class="n">grammar</span><span class="p">:</span> <span class="n">grammar</span><span class="o">.</span><span class="n">unload</span><span class="p">()</span>
    <span class="n">grammar</span> <span class="o">=</span> <span class="bp">None</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">Command-module for direct opening of <strong>user-defined targets</strong></a><ul>
<li><a class="reference external" href="#installation">Installation</a></li>
<li><a class="reference external" href="#commands">Commands</a></li>
<li><a class="reference external" href="#customization">Customization</a></li>
<li><a class="reference external" href="#configuration-examples">Configuration examples</a><ul>
<li><a class="reference external" href="#configuration-bringme-en-txt">Configuration &#8220;_bringme-en.txt&#8221;</a></li>
</ul>
</li>
<li><a class="reference external" href="#module-source-code">Module source code</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="mod-_taskbar.html" title="previous chapter">Command-module for <strong>taskbar</strong> and icon tray access</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="mod-_lockscreen.html" title="next chapter">Command-module for <strong>screen locking</strong></a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/mod-_bringme.txt">Show Source</a></li>
            </ul>
          <h3>Quick search</h3>
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="mod-_lockscreen.html" title="Command-module for screen locking"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mod-_taskbar.html" title="Command-module for taskbar and icon tray access"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Dragonfly-modules v0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Christo Butcher.
      Last updated on Apr 10, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.1.
    </div>
  </body>
</html>